// Person.h
#include <iostream>
#include <string>
using namespace std;

class Person
{
public:
    Person() { cout << "Person::Person()" << endl; }
    virtual ~Person() { cout << "Person::~Person()" << endl; }
    virtual void print() { cout << "Person::print()" << endl; }
    
protected:
    string name;
private:
    int age;
};

class Student : public Person
{
public:
    Student() { cout << "Student::Student()" << endl; }
    ~Student() { cout << "Student::~Student()" << endl; }
    virtual void print() { cout << "Student::print()" << endl; }

private:
    int id;
};

class Teacher : public Person
{
public:
    Teacher() { cout << "Teacher::Teacher()" << endl; }
    ~Teacher() { cout << "Teacher::~Teacher()" << endl; }
    virtual void print() { cout << "Teacher::print()" << endl; }

private:
    int id;
};

void doSomething(Person* p)
{
    p->print();
}

int main()
{
    Person *p = new Student;
    p->print();
    delete p;
    p = nullptr;

    Student *p1 = new Student;
    Teacher *p2 = new Teacher;
    doSomething(p1);
    doSomething(p2);

    delete p1;
    p1 = nullptr;
    delete p2;
    p2 = nullptr;


    return 0;
}